package com.mogist.hqc.module.product.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.mogist.hqc.R
import com.mogist.hqc.entitys.response.ProductOrderVo
import talex.zsw.basecore.util.MathTool
import talex.zsw.basecore.util.RegTool

/**
 * 作者：赵小白 email:vvtale@gmail.com  
 * 修改人：
 * 修改时间：
 * 修改备注：
 */
class ProductOrderItemAdapter : BaseQuickAdapter<ProductOrderVo, BaseViewHolder>(R.layout.item_product_order_item)
{
    override fun convert(helper: BaseViewHolder, item: ProductOrderVo)
    { // iTvTitle iTvPrice iLLCount iIvReduce iTvCount iIvAdd
        helper.setText(R.id.iTvTitle, item.name)
                .setText(R.id.iTvCount, item.count.toString())
                .setEnabled(R.id.iIvReduce, item.count > 0)
                .setEnabled(R.id.iIvAdd, item.count < 99)
                .addOnClickListener(R.id.iIvReduce)
                .addOnClickListener(R.id.iIvAdd)
                .addOnClickListener(R.id.iLLCount)
                .setGone(R.id.iIvReduce, item.count > 0)
                .setGone(R.id.iTvCount, item.count > 0)


        if (RegTool.isEmpty(item.price))
        {
            helper.setText(R.id.iTvPrice, "")
                    .setGone(R.id.iLLCount, false)
        }
        else
        {
            helper.setText(R.id.iTvPrice, "￥" + MathTool.roundStr(item.price, 2))
                    .setGone(R.id.iLLCount, true)
        }
    }
}